package com.android.pdd.baseapp.mvp.presenter;

import com.android.pdd.baseapp.api.my.MApiClient;
import com.android.pdd.baseapp.model.HttpResponse;
import com.android.pdd.baseapp.mvp.view.CheckVersionView;
import com.blankj.utilcode.util.AppUtils;
import com.lg.meng.base.BasePresenter;
import com.lg.meng.model.ResponseVersionData;

/**
 * Author: xx
 * Date: 2019/12/12
 * Description:
 */
public class CheckVersionPresenter extends BasePresenter<CheckVersionView> {
    public void checkVersion() {
        MApiClient.getInstance().checkVersion(AppUtils.getAppVersionCode())
                .subscribe(simpleObserver(new Callback<HttpResponse<ResponseVersionData>>() {
                    @Override
                    public void resultSuccess(HttpResponse<ResponseVersionData> data) {
                        if (data.getData() == null) {
                            view.nofindNewVersion();
                        } else {
                            view.findNewVersion(data.getData());
                        }
                    }

                    @Override
                    public void resultError(Throwable e) {
                        view.checkVersionFailed(e);
                    }
                }));
    }
}
